/**
 * 3
 *  
 * @Author : Ruoyu Wang
 * @DateTime : 24-9-27 下午6:22
 */

#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> nums(n);
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    unordered_map<int, int> map;
    unordered_set<int> set;

    int sum = 0;
    bool flag = false;

    for (int num: nums) {
        map[num]++;
    }

    for (const auto &pair: map) {
        if (pair.second > 1) {
            flag = true;
            set.insert(pair.first);
        }
    }

    for (int num: set) {
        sum += num;
    }

    int res = flag ? sum : -1;

    cout << res << endl;

    return 0;
}